
//碰撞盒圆形
class CCOLLISION_CIRCLE extends CCOLLISION {

	private judge_r:number=0
	//形状碰撞开关
	private shape_collision:boolean=false
	
	
	public constructor(ptr:CBASE,x:number,y:number,r:number,color?:number) {
		 super(ptr)
		  this.judgetype=judgetype.circle
		  this.shape=new egret.Shape();
		  this.setshape(x,y,r,color)
		  this.parent.addChild(this.shape)
		  this.shapeCollisionSwitch=false
	}
	public set shapeCollisionSwitch(a:boolean) //是否开启形状碰撞提示
	{
		
		this.shape_collision=a
		if(a)
		{
			this.shape.touchEnabled=true;
			this.shape.alpha=0.5
		}
		else{
			this.shape.touchEnabled=false;
		    this.shape.alpha=0
		}
	}
	public get type():judgetype
	{
		return this.judgetype
	}
	public NormalVector()
	{
		return this.judge_r
	}
	public get relpoint():egret.Point
	{
      	var vector:egret.Point
		
			  var local:egret.Point=new egret.Point;
			   local.x=this.shapepoint[0].x+this.shape.x;
		       local.y=this.shapepoint[0].y+this.shape.y;
			   var anchoroff=new egret.Point(this.parent.anchorOffsetX,this.parent.anchorOffsetY);
			   var nowpoint= this.Pointrevolve(local,anchoroff,this.parent.rotation);
			   vector=new egret.Point(nowpoint.x+this.parent.x,nowpoint.y+this.parent.y);
		return vector
	}
	public get r():number
	{
		return this.judge_r
		
	}
	public setshape(x:number,y:number,r:number,color?:number)
	{
		  this.shape.graphics.clear();
		  this.shapepoint.splice(0,this.shapepoint.length)
		  this.judge_r=r
		  
		  if(color==undefined)
		  this.shape.graphics.beginFill(0xff000,1);
		  else
          this.shape.graphics.beginFill(color,1);
		  this.shape.graphics.drawCircle(0,0,r)
		  this.shape.x=x,this.shape.y=y;
		
		  this.shapepoint.push(new egret.Point(x,y))
		  this.shape.graphics.endFill();
		 
		  this.shape.graphics.beginFill(0xfffff,1);
		  this.shape.graphics.drawCircle(this.shape.anchorOffsetX,this.shape.anchorOffsetY,5)
		  this.shape.graphics.endFill();
		 
	}

	

}